/*
 * @Author: miteng 973203639@qq.com
 * @Date: 2024-03-25 10:46:12
 * @LastEditors: 郝奔 1425466221@qq.com
 * @LastEditTime: 2024-12-04 16:09:08
 * @FilePath: /dqbasic-vue3/src/framework/api/application.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved.
 */
import { default as request, cloud } from '@/framework/utils/request';
import { ResultData } from '@/framework/api/common/index';
import {
  AppListType,
  FormDataType,
  DetailIdType,
  AppSecretType
} from './types';
export default {
  // 获取应用列表
  getList(params: Partial<AppListType>): Promise<ResultData<AppListType[]>> {
    return request({
      url: cloud.openplat + '/integrate/app/getList',
      method: 'get',
      params: params
    });
  },
  // 获取应用数据
  getAppById(params: DetailIdType): Promise<ResultData<AppListType>> {
    return request({
      url: cloud.dqBasic + '/sysApp/detail',
      method: 'get',
      params
    });
  },
  // 发布应用
  editReleaseStatus(data: Partial<AppListType>): Promise<ResultData<null>> {
    return request({
      url: cloud.openplat + '/integrate/app/editReleaseStatus',
      method: 'post',
      data
    });
  },
  // 添加应用
  addIntegratedApp(data: Partial<FormDataType>): Promise<ResultData<string>> {
    return request({
      url: cloud.openplat + '/integrate/app/add',
      method: 'post',
      data
    });
  },
  // 修改应用
  edit(data: Partial<FormDataType>): Promise<ResultData<null>> {
    return request({
      url: cloud.openplat + '/integrate/app/edit',
      method: 'post',
      data
    });
  },
  // 删除角色
  deleteApp(data: DetailIdType): Promise<ResultData<null>> {
    return request({
      url: cloud.openplat + '/integrate/app/delete',
      method: 'post',
      data
    });
  },
  // 应用名称校验
  checkAppName(params: Partial<AppListType>): Promise<ResultData<null>> {
    return request({
      url: cloud.openplat + '/integrate/app/checkAppName',
      method: 'get',
      params
    });
  },
  // 应用编码校验
  checkAppCode(params: Partial<AppListType>): Promise<ResultData<null>> {
    return request({
      url: cloud.openplat + '/integrate/app/checkAppCode',
      method: 'get',
      params
    });
  },

  // 获取应用秘钥
  getAppSecret(params: DetailIdType): Promise<ResultData<AppSecretType>> {
    return request({
      url: cloud.openplat + '/integrate/app/getAppSecret',
      method: 'get',
      params
    });
  },
  // 获取应用列表不分页
  detail(params: DetailIdType): Promise<ResultData<AppListType>> {
    return request({
      url: cloud.openplat + '/integrate/app/detail',
      method: 'get',
      params
    });
  },
  // 选人
  getManagingOrgUserList(
    params: DetailIdType
  ): Promise<ResultData<AppListType[]>> {
    return request({
      url: cloud.openplat + '/integrate/app/selectMaintainerComponent',
      method: 'get',
      params
    });
  },
  // 根据组织搜索
  searchOrgName(params: Record<string, string>): Promise<ResultData<AppListType[]>> {
    return request({
      url: cloud.openplat + '/integrate/app/maintainer/searchOrgName',
      method: 'get',
      params: {
        orgName: params.name
      }
    });
  },
  // 搜用户姓名或者账号
  searchUserName(params: Record<string, string>): Promise<ResultData<AppListType[]>> {
    return request({
      url: cloud.openplat + '/integrate/app/maintainer/searchUserName',
      method: 'get',
      params: {
        nameOrAccount: params.name
      }
    });
  }
};
